<!-- BeginDsi "dsi/head.html" -->
<!DOCTYPE html>
<html lang="en">
<head>
    <title>Embedthis GoAhead 3.1.1 Documentation</title>
    <meta name="keywords" content="embedded web server, web server software, embedded HTTP, application web server, 
        embedded server, small web server, HTTP server, library web server, library HTTP, HTTP library" />
    <meta name="description" content="Embedthis Sofware provides commercial and open source embedded web servers for 
        devices and applications." />
	<meta name="robots" content="index,follow" />
	<link href="../../../doc.css" rel="stylesheet" type="text/css" />
	<link href="../../../print.css" rel="stylesheet" type="text/css" media="print"/>
    <!--[if IE]>
    <link href="../../../iehacks.css" rel="stylesheet" type="text/css" />
    <![endif]-->
    <link href="http://www.google.com/cse/style/look/default.css" type="text/css" rel="stylesheet" />
    <script type="text/javascript">
        var _gaq = _gaq || [];
        _gaq.push(['_setAccount', 'UA-179169-5']);
        _gaq.push(['_trackPageview']);
        (function() {
            var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
            ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
            var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
        })();
    </script>
</head>

<body>
    <div class="top">
        <a class="logo" href="http://embedthis.com/products/goahead/">&nbsp;</a>
        <div class="topRight">
            <div class="search">
                <div id="cse-search-form"></div>
                <div class="version">Embedthis GoAhead 3.1.1</div>
            </div>
        </div>
        <div class="crumbs">
            <a href="../../../index.html">Home</a>
<!-- EndDsi -->
             &gt;<a href="index.html">Source Code</a>&gt; <b>Building with Make</b>
        </div>
    </div>
    <div class="content">
        <div class="contentRight">
            <h1>Quick Nav</h1>
            <ul>
                <li><a href="#makefiles">Platform Makefile</a></li>
                <li><a href="#nmake">Windows Nmake</a></li>
                <li><a href="#modifying">Modifying Defaults</a></li>
                <li><a href="#installing">Installing</a></li>
                <li><a href="#openssl">OpenSSL support</a></li>
                <li><a href="#cross">Cross Compiling</a></li>
                <li><a href="#toolchain">Specifying a Tool Chain</a></li>
                <li><a href="bit.html">Building with Bit</a></li>
                <li><a href="ide.html">Building with an IDE</a></li>
            </ul>
<!-- BeginDsi "dsi/sourceSeeAlso.html" -->
            <h1>See Also</h1>
            <ul class="nav">
                <li><a href="../../../guide/goahead/source/index.html">Working with Source</a></li>
                <li><a href="../../../guide/goahead/source/building.html">Building From Source</a></li>
                <li><a href="../../../guide/goahead/source/porting.html">Porting Guide</a></li>
                <li><a href="../../../ref/goahead/index.html">Programmers Reference</a></li>
                <li><a href="../../../guide/goahead/programmers/embedding.html">Embedding GoAhead</a></li>
                <li><a href="../../../guide/goahead/programmers/handlers.html">GoAhead Handlers</a></li>
                <li><a href="../../../guide/goahead/programmers/migrating.html">Migrating to GoAhead 3</a></li>
                <li><a href="../../../guide/goahead/users/index.html">Users Guide</a></li>
                <li><a href="../../../product/changeLog.html">Change Log</a></li>
            </ul>
<!-- EndDsi -->
        </div>
        <div class="contentLeft">
            <h1>Building with Make or Nmake</h1>
            <p>This document describes the process to build the software from source using Make or Nmake on Windows.
                First make sure you have read <a href="building.html">Building from Source</a> to prepare your build
                environment. </p>
            
            <a name="makefiles"></a>
            <h2>Platform Makefiles</h2>
            <p>GoAhead provides a suite of generated, pre-configured Makefiles for common platforms. 
            These are simple flat makefiles that build a default configuration of GoAhead for a specific operating
            system. These makefiles are provided under the <em>./projects</em> directory.</p>
            <p> A top level Makefile is also provided that detects your operating system and CPU architecture and
            then invokes the appropriate project Makefile for your system. For example:</p>
<pre>$ <b>make</b>
make --no-print-directory -f projects/goahead-macosx-default.mk all
...
</pre>
            <a name="nmake"></a>
            <h3>Windows Nmake</h3>
            <p>On Windows, a <em>make.bat</em> file is provided to to invoke nmake. The make.bat file first invokes
            <em>projects/windows.bat</em> which runs the Visual Studio <em>vcvarsall.bat</em> procedure
            to setup the necessary Visual Studio environment variables for compiling.</p>
            <p>To build on Windows with nmake, type:
            <pre>$ <b>make</b>
nmake -f projects\goahead-windows.nmake
...
</pre>
            <a name="modifying"></a>
            <h3>Modifying the Makefile Defaults</h3>
            <p>You do not use the configure program when building via Make, that is used only for building with Bit. 
            Rather, you supply configuration options directly to Make. These options override default values defined by the
            projects/goahead-OS-default.mk makefile and by the projects/goahead-OS-debug-bit.h file. For example, to disable use of SQLite:</p>
            <pre>$ make <b>BIT_PACK_SQLITE=0</b> </pre>
            <p>Extension packs are enabled by setting their corresponing BIT_PACK_NAME option to 1. Disable by setting
            to zero. Some packs requires a path to locate libraries and headers. Use BIT_PACK_NAME_PATH to define
            the path to the extension pack.</p>
            <p>To see the list of configurable options, run:</p>
            <pre>$ <b>make help</b>
usage: make [clean, compile, deploy, install, run, uninstall]
With make, the default configuration can be modified by setting make
variables. Set to 0 to disable and 1 to enable:
  PROFILE                           # Select default or static for static linking
  BIT_GOAHEAD_ACCESS_LOG            # Enable request access log (true|false)
  BIT_GOAHEAD_CLIENT_CACHE          # List of extensions to cache in the client
  BIT_GOAHEAD_CLIENT_CACHE_LIFESPAN # Time in seconds to cache in the client
  BIT_GOAHEAD_CA_FILE               # File of client certificates (path)
  BIT_GOAHEAD_CERTIFICATE           # Server certificate for SSL (path)
  BIT_GOAHEAD_CIPHERS               # SSL cipher suite (string)
  BIT_GOAHEAD_CGI                   # Enable the CGI handler (true|false)
  BIT_GOAHEAD_CGI_BIN               # Directory CGI programs (path)
  BIT_GOAHEAD_JAVASCRIPT            # Enable the Javascript JST handler (true|false)
  BIT_GOAHEAD_KEY                   # Server private key for SSL (path)
  BIT_GOAHEAD_LEGACY                # Enable the GoAhead 2.X legacy APIs (true|false)
  BIT_GOAHEAD_LIMIT_BUFFER          # I/O Buffer size. Also chunk size.
  BIT_GOAHEAD_LIMIT_FILENAME        # Maximum filename size
  BIT_GOAHEAD_LIMIT_HEADER          # Maximum HTTP single header size
  BIT_GOAHEAD_LIMIT_HEADERS         # Maximum HTTP header size
  BIT_GOAHEAD_LIMIT_NUM_HEADERS     # Maximum number of headers
  BIT_GOAHEAD_LIMIT_PASSWORD        # Maximum password size
  BIT_GOAHEAD_LIMIT_POST            # Maximum incoming body size
  BIT_GOAHEAD_LIMIT_PUT             # Maximum PUT body size ~ 200MB
  BIT_GOAHEAD_LIMIT_SESSION_LIFE    # Session lifespan in seconds (30 mins)
  BIT_GOAHEAD_LIMIT_SESSION_COUNT   # Maximum number of sessions to support
  BIT_GOAHEAD_LIMIT_STRING          # Default string allocation size
  BIT_GOAHEAD_LIMIT_TIMEOUT         # Request inactivity timeout in seconds
  BIT_GOAHEAD_LIMIT_URI             # Maximum URI size
  BIT_GOAHEAD_LIMIT_UPLOAD          # Maximum upload size ~ 200MB
  BIT_GOAHEAD_LISTEN                # Addresses to listen to (["http://IP:port", ...])
  BIT_GOAHEAD_LOGFILE               # Default location and level for debug log
  BIT_GOAHEAD_LOGGING               # Enable application logging (true|false)
  BIT_GOAHEAD_PAM                   # Enable Unix Pluggable Auth Module (true|false)
  BIT_GOAHEAD_PUT_DIR               # Define the directory for file uploaded via PUT
  BIT_GOAHEAD_REALM                 # Authentication realm (string)
  BIT_GOAHEAD_REPLACE_MALLOC        # Replace malloc with non-fragmenting allocator
  BIT_GOAHEAD_SSL                   # To enable SSL
  BIT_GOAHEAD_STATIC                # Build with static linking (true|false)
  BIT_GOAHEAD_STEALTH               # Run in stealth mode. Disable OPTIONS, TRACE
  BIT_GOAHEAD_TRACING               # Enable debug tracing (true|false)
  BIT_GOAHEAD_TUNE                  # Optimize (size|speed|balanced)
  BIT_GOAHEAD_UPLOAD                # Enable file upload (true|false)
  BIT_GOAHEAD_UPLOAD_DIR            # Define directory for uploaded files (path)
  BIT_PACK_EST                      # Enable the EST SSL stack
  BIT_PACK_NANOSSL                  # Enable the Mocana NanoSSL stack
  BIT_PACK_MATRIXSSL                # Enable the MatrixSSL SSL stack
  BIT_PACK_OPENSSL                  # Enable the OpenSSL SSL stack
  BIT_ROM                           # Build for ROM without a file system
  BIT_STACK_SIZE                    # Define the VxWorks stack size
For example, to disable CGI:
  make BIT_GOAHEAD_CGI=0
Other make variables:
  ARCH               # CPU architecture (x86, x64, ppc, ...)
  OS                 # Operating system (linux, macosx, windows, vxworks, ...)
  CC                 # Compiler to use 
  LD                 # Linker to use
  DEBUG              # Set to debug or release for debug or optimized builds
  CONFIG             # Output directory for built items. Defaults to OS-ARCH-PROFILE
  CFLAGS             # Add compiler options. For example: -Wall
  DFLAGS             # Add compiler defines. For example: -DCOLOR=blue
  IFLAGS             # Add compiler include directories. For example: -I/extra/includes
  LDFLAGS            # Add linker options
  LIBPATHS           # Add linker library search directories. For example: -L/libraries
  LIBS               # Add linker libraries. For example: -lpthreads
  PROFILE            # Build profile, used in output products directory name
</pre>
            <p>By defining the make variables such as CC and CFLAGS, you can modify the compiler options. This is the
            technique used when cross-compiling. For more details, see <a href="#cross">Cross Compiling</a> below.</p>
            <a name="installing"></a>
            <h2 class="section">Installing with Make</h2>
            <p>You can install the newly built software via:</p>
            <pre>sudo make install</pre>
            <p>You can remove by:</p>
            <pre>
sudo make uninstall
</pre>
            <h3>Warning: Must Use Same Option</h3>
            <p>It is essential when invoking <em>make install</em>, that you provide the same make flags and options
                as you did when compiling. This is because the Makefile will conditionally install only the selected
                components for those options.</p>
            <p>For example, to build and install OpenSSL:</p>
                <pre>$ make <b>BIT_PACK_OPENSSL=1 BIT_PACK_OPENSSL_PATH=/usr/src/openssl</b> compile
$ sudo make <b>BIT_PACK_OPENSSL=1 BIT_PACK_OPENSSL_PATH=/usr/src/openssl</b> install</pre>
            <a name="deploy"></a>
            <h3>Deploying</h3>
            <p>If you need to deploy to a different system or capture the build products, you can install to a specific
            directory via: </p>
            <pre>make deploy</pre>
            <p>This will install to the <em>deploy</em> directory under the output platform directory.</p>

            <a name="openssl"></a>
            <h3>Supporting OpenSSL</h3>
            <p>If OpenSSL is required to provide SSL support, you must specify the path to the OpenSSL source
              directory. For example:</p>
            <pre>make BIT_PACK_OPENSSL=1 BIT_PACK_OPENSSL_PATH=/path/to/openssl compile</pre>
            <p>If you are using a binary OpenSSL distribution, provide the path where the OpenSSL libraries are located
              (typically /usr/lib).</p>
            <pre>make BIT_PACK_OPENSSL=1 BIT_PACK_OPENSSL_PATH=/usr/lib compile</pre>
            <a id="cross"></a>
            <h2 class="section">Cross Compiling with Make</h2>
            <p>Building a product for platform different to that of the local system is called <em>cross compiling</em>.
            Sometimes this compiling is just for a different instruction set (say x64 instead of x86). Other
            times, it is for a completely different operating system and/or CPU architecture. In such cases, a
            cross-compiler is typically required to build for the target platform.</p>
            <p>GoAhead supplies makefiles for Linux, Windows, FreeBSD, MAC OSX and VxWorks. To cross compile, you invoke 
            the relevant project makefile and pass the required CPU architecture as a make variable. For example, to 
            cross compile for VxWorks on ARM:
            <pre>
make -f projects/goahead-vxworks-default.mk ARCH=arm PROFILE=debug
</pre>
            <p>When make runs, it places the output products (executables, libraries and objects) in a platform-specific 
            output directory. This is named using the form: OS-ARCH-PROFILE. For example: vxworks-arm-debug. In this 
            manner, make can be invoked multiple times, once for each target platform and the results will be captured
            in separate platform output directories. Some of the supported architectures for the ARCH field are:
            arm, mips, ppc, x64 and x86. The PROFILE is a descriptive name chosen by you for your configuration.</p>
            <p>If there is not a makefile for your  target operating system, copy the closest makefile and edit to 
            suit your target platform.</p>

            <h3>Specifying the CPU</h3>
            <p>The build will generic CPU type within the specified  architecture.
            To override the default choice and specify a CPU type within an architecture, use the CPU variable.
            For example:/p>
            <pre>make OS=vxworks ARCH=arm CPU=arm7tdmi</pre>

            <a name="toolchain"></a>
            <h3>Specifying a Tool Chain</h3>
            <p>You may need to specify where Make can locate your cross-compiler and other tools.
            You can supply these via the make variables: CC, CFLAGS, DFLAGS, IFLAGS, LD and LDFLAGS. 
            <p>For example:</p>
            <pre>
make CC=/opt/bin/ccarm.exe LD=/opt/bin/ccarm.exe ARCH=arm PROFILE=release
    -f projects/goahead-vxworks-default.mk 
</pre>

            <a name="static"></a>
            <h2>Static Building</h2>
            <p>If you require a static build without the ability to dynamically load modules, use the <em>static</em>
                makefile profile. For example:</p>
                <pre>make PROFILE=static</pre>

            <a name="vxworks"></a>
            <h2>Building for VxWorks</h2>
            <p>Before building for VxWorks, you must define the WIND_* environment variables via the 
              <em>wrenv.sh</em> script provided with VxWorks. This defines the WIND_BASE, WIND_HOST_TYPE and 
              other required environment variables.</p>
              <p>The command below runs wrenv.sh and defines the WIND variables
              in the current shell's environment.</p>
            <pre>eval `/WindRiver/wrenv.sh -p vxworks-6.8 -o print_env -f sh`</pre>
            <p>Once defined, you can invoke make.</p>
            <pre>make OS=vxworks</pre>

            <p>If you require a static build, set the profile to "static".</p>
<pre>make OS=vxworks PROFILE=static</pre>     

        </div>
    </div>
<!-- BeginDsi "dsi/bottom.html" -->
	<div class="bottom">
		<p class="footnote"> 
            <a href="../../../product/copyright.html" >&copy; Embedthis Software LLC, 2003-2013.
            All rights reserved. Embedthis and Embedthis GoAhead are trademarks of Embedthis Software LLC.</a>
		</p>
	</div>
    <script src="http://www.google.com/jsapi" type="text/javascript"></script>
    <script type="text/javascript"> 
      google.load('search', '1', {language : 'en'});
      google.setOnLoadCallback(function() {
        var customSearchControl = new google.search.CustomSearchControl(
          '000262706376373952077:1hs0lhenihk');
        customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
        var options = new google.search.DrawOptions();
        options.enableSearchboxOnly("http://embedthis.com/search.html");
        customSearchControl.draw('cse-search-form', options);
      }, true);
    </script>
</body>
</html>
